:root {
    color-scheme: light;
    --bg: #e7f0eb;
    --surface: #fffdf7;
    --surface-2: #f5f7ef;
    --ink: #18382f;
    --muted: #617c72;
    --line: #c8ded5;
    --brand: #25735f;
    --brand-2: #46a389;
    --accent: #d78a32;
    --danger: #b84b4b;
    --shadow: 0 18px 38px rgba(24, 56, 47, 0.16);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 16% 12%, rgba(255, 255, 255, 0.72), transparent 30%),
        linear-gradient(140deg, #d6e9e3 0%, #e9efe1 48%, #d9e8ed 100%);
    color: var(--ink);
    font-family: "Segoe UI", "Microsoft YaHei", "Noto Sans CJK SC", Arial, sans-serif;
}

.app-shell {
    width: min(1440px, calc(100% - 32px));
    margin: 24px auto;
    background: rgba(255, 253, 247, 0.9);
    border: 1px solid rgba(88, 137, 120, 0.28);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: center;
    padding: 22px 26px 18px;
    border-bottom: 1px solid var(--line);
    background: rgba(250, 252, 246, 0.82);
}

.topbar-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--brand);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

h1, h2, p {
    margin: 0;
}

h1 {
    font-size: clamp(26px, 3vw, 40px);
    letter-spacing: 0;
}

h2 {
    font-size: 18px;
}

.status-strip {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.status-strip span {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 12px;
    background: white;
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

.logout-link {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    color: var(--brand);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}

.logout-link:hover {
    border-color: var(--brand-2);
    background: #edf8f3;
}

.dashboard {
    display: grid;
    grid-template-columns: minmax(560px, 1.45fr) minmax(420px, 0.9fr);
    gap: 0;
}

.library-panel,
.control-panel {
    padding: 22px;
}

.library-panel {
    border-right: 1px solid var(--line);
}

.panel-head,
.result-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.library-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.panel-head p,
.result-head span,
.slot-label,
.metric span,
.trait-output span,
.target-box label {
    color: var(--muted);
    font-size: 13px;
}

.segmented {
    display: inline-grid;
    grid-template-columns: repeat(3, 1fr);
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #edf4ef;
    padding: 3px;
}

button {
    font: inherit;
}

.segmented-btn {
    border: 0;
    background: transparent;
    color: var(--muted);
    border-radius: 999px;
    padding: 8px 12px;
    cursor: pointer;
}

.mini-btn,
.icon-btn,
.card-btn {
    border: 1px solid var(--line);
    background: white;
    color: var(--brand);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
}

.mini-btn {
    min-height: 38px;
    padding: 0 12px;
}

.mini-btn.alt {
    color: var(--accent);
}

.segmented-btn.active {
    color: white;
    background: var(--brand);
}

.fish-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
    gap: 12px;
}

.fish-card {
    min-height: 168px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.fish-card:hover {
    transform: translateY(-2px);
    border-color: var(--brand-2);
    box-shadow: 0 10px 22px rgba(37, 115, 95, 0.12);
}

.fish-card.selected {
    border-color: var(--brand);
    background: #edf8f3;
    box-shadow: inset 0 0 0 1px var(--brand);
}

.fish-card.disabled {
    display: none;
}

.fish-title {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: flex-start;
}

.fish-title strong {
    font-size: 16px;
}

.sex-pill {
    min-width: 30px;
    text-align: center;
    border-radius: 999px;
    color: white;
    background: var(--brand);
    padding: 3px 8px;
    font-weight: 700;
    font-size: 12px;
}

.sex-pill.female {
    background: var(--accent);
}

.badge-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.badge {
    border-radius: 999px;
    background: #e6f0ea;
    padding: 5px 8px;
    font-size: 12px;
    color: #2f604f;
}

.gene-line {
    margin-top: auto;
    color: var(--muted);
    font-family: Consolas, "Courier New", monospace;
    font-size: 12px;
    line-height: 1.45;
}

.card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.card-btn {
    min-height: 32px;
    font-size: 12px;
}

.card-btn.danger {
    color: var(--danger);
}

.control-panel {
    background: rgba(245, 247, 239, 0.74);
}

.pair-box {
    display: grid;
    grid-template-columns: 1fr 42px 1fr;
    gap: 10px;
    align-items: stretch;
}

.pair-slot {
    min-height: 94px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    padding: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.pair-slot strong {
    font-size: 18px;
}

.pair-slot small {
    color: var(--muted);
}

.pair-symbol {
    align-self: center;
    justify-self: center;
    color: var(--brand);
    font-size: 30px;
    font-weight: 800;
}

.action-row,
.target-row {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

.primary-btn,
.ghost-btn {
    border: 0;
    border-radius: 8px;
    min-height: 42px;
    padding: 0 16px;
    cursor: pointer;
    font-weight: 700;
}

.primary-btn {
    flex: 1;
    background: var(--brand);
    color: white;
}

.primary-btn:hover {
    background: #1d604f;
}

.ghost-btn {
    background: white;
    border: 1px solid var(--line);
    color: var(--brand);
}

.compact {
    flex: 0 0 118px;
}

.target-box,
.result-panel,
.recommend-panel {
    margin-top: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.84);
    padding: 14px;
}

.target-box label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
}

input,
select {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 12px;
    color: var(--ink);
    font: inherit;
    background: white;
}

input[readonly] {
    color: var(--muted);
    background: #eef4ef;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 18px;
}

.metric {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    padding: 12px;
}

.metric strong {
    display: block;
    margin-top: 8px;
    font-size: 24px;
}

.trait-output {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.trait-output div {
    border-radius: 8px;
    background: var(--surface-2);
    padding: 12px;
}

.trait-output strong {
    display: block;
    margin-top: 6px;
    font-size: 18px;
}

.chart-area {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.bar-row {
    display: grid;
    grid-template-columns: 82px 1fr 54px;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.bar-track {
    height: 10px;
    background: #e1ebe5;
    border-radius: 999px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--brand), var(--brand-2));
}

.recommend-list {
    display: grid;
    gap: 10px;
}

.recommend-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fffdf7;
}

.recommend-card strong {
    font-size: 16px;
}

.recommend-card p {
    color: var(--muted);
    margin-top: 6px;
    font-size: 13px;
    line-height: 1.5;
}

.risk-high {
    color: var(--danger);
}

.loading {
    opacity: 0.62;
    pointer-events: none;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(18, 40, 34, 0.42);
}

.modal-backdrop.hidden {
    display: none;
}

.modal-card {
    width: min(920px, 100%);
    max-height: min(760px, calc(100vh - 36px));
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 28px 64px rgba(12, 35, 29, 0.28);
    padding: 20px;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    font-size: 24px;
    line-height: 1;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.form-grid label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.form-message {
    min-height: 22px;
    margin-top: 12px;
    color: var(--danger);
    font-size: 13px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 12px;
}

.modal-actions .primary-btn,
.modal-actions .ghost-btn {
    flex: 0 0 auto;
}

@media (max-width: 1050px) {
    .dashboard {
        grid-template-columns: 1fr;
    }

    .library-panel {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }
}

@media (max-width: 680px) {
    .app-shell {
        width: min(100% - 18px, 1440px);
        margin: 9px auto;
    }

    .topbar,
    .panel-head,
    .action-row,
    .target-row,
    .modal-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .pair-box,
    .metric-grid,
    .trait-output {
        grid-template-columns: 1fr;
    }

    .pair-symbol {
        font-size: 24px;
    }

    .library-actions,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-grid {
        display: grid;
    }
}

.login-page {
    min-height: 100vh;
    background:
        linear-gradient(90deg, rgba(3, 14, 26, 0.9), rgba(3, 19, 32, 0.7) 42%, rgba(5, 28, 45, 0.42)),
        url("images/bg.jpg") center / cover fixed,
        #06131f;
    color: #f4fbff;
}

.login-shell {
    width: min(1120px, calc(100% - 36px));
    min-height: 100vh;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    gap: 28px;
    align-items: center;
}

.login-copy {
    max-width: 720px;
}

.login-copy h1 {
    margin-bottom: 18px;
    color: #f4fbff;
    font-size: clamp(36px, 5vw, 62px);
}

.login-copy p:not(.eyebrow) {
    color: rgba(244, 251, 255, 0.76);
    font-size: 18px;
    line-height: 1.75;
}

.login-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 24px;
}

.login-tags span {
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #f4fbff;
    font-weight: 700;
}

.login-card {
    display: grid;
    gap: 16px;
    padding: 28px;
    border: 1px solid rgba(196, 226, 238, 0.2);
    border-radius: 8px;
    background: rgba(7, 22, 35, 0.88);
    box-shadow: 0 22px 54px rgba(0, 0, 0, 0.34);
    backdrop-filter: blur(16px);
}

.login-card h2 {
    color: #f4fbff;
    font-size: 28px;
}

.login-card label {
    display: grid;
    gap: 8px;
    color: rgba(244, 251, 255, 0.72);
    font-size: 13px;
    font-weight: 700;
}

.login-card input {
    border-color: rgba(255, 255, 255, 0.16);
    background: rgba(1, 12, 20, 0.62);
    color: #f4fbff;
}

.login-card .primary-btn {
    width: 100%;
    background: linear-gradient(90deg, #25735f, #58c7ab);
}

.login-error {
    padding: 12px 14px;
    border: 1px solid rgba(255, 138, 114, 0.3);
    border-radius: 8px;
    background: rgba(255, 138, 114, 0.12);
    color: #ffd4cc;
}

.login-note {
    color: rgba(244, 251, 255, 0.62);
    font-size: 13px;
}

@media (max-width: 860px) {
    .login-shell {
        grid-template-columns: 1fr;
        padding: 28px 0;
    }
}
